import { tt_impl } from "./ttapi_impl_web/ttimpl_web.js"
import { tt } from "./ttapi_interface/ttapi.js"
import * as tt2 from "./ttapi_layer2/ttlayer2.js";
import { MainUI } from "./usercode/MainUI.js";
import { State_Begin } from "./usercode/State_Begin.js";


async function StartEditor() {


    console.warn("==初始化扩展==");
    let b = await tt2.QExt.Init();
    if (b) {
        tt2.QExt.SetDebug(true);//自己扩展的小界面，用处不大，主要给f5 f12 整俩个按钮
    }
    //首先 初始化 TTEngine ，TTEngine 是一套极简的渲染引擎
    let impl = new tt_impl.ttimpl_browser();
    let canvas = window.document.createElement("canvas");
    window.document.body.append(canvas);
    canvas.style.width = "100%";
    canvas.style.height = "100%";
    canvas.style.border = "0px";
    canvas.style.margin = "0px";
    impl.Init(canvas);

    let userdata = new MainUI();
    let deffonturl = "data/hzk12.ttfont.bin";
    let debug = true;

    let app = new tt2.QFrame_App<MainUI>(userdata, deffonturl, debug);

    await app.Start();


    app.ChangeState(new State_Begin());
}

window.onload = () => {

    StartEditor();
}